package realm.inorder.itmill.ui.panel.initial;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.GridLayout;

@org.springframework.stereotype.Component
public class InitialLayout extends GridLayout implements InitializingBean {

	@Autowired
	private LoginPanel loginPanel;

	public InitialLayout() {
		super(2, 1);
	}

	public void afterPropertiesSet() throws Exception {
		initComponents();
	}

	private void initComponents() {
		this.addComponent(initLeftLayout());
		this.addComponent(initRightLayout());
	}

	private Component initLeftLayout() {
		GridLayout gridLayout = new GridLayout(1, 2);
		gridLayout.setMargin(false, true, false, true);
		gridLayout.addComponent(new WhatPanel());
		gridLayout.addComponent(new HowPanel());
		
		return gridLayout;
	}
	
	private Component initRightLayout() {
		GridLayout gridLayout = new GridLayout(1, 1);
		
		gridLayout.addComponent(loginPanel);
		
		return gridLayout;
	}
	
}
